package com.cityfood.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cityfood.mapper.CfAttributeValueMapper;
import com.cityfood.pojo.CfAttributeValue;
import com.cityfood.pojo.CfAttributeValueExample;
import com.cityfood.pojo.CfAttributeValueExample.Criteria;
import com.cityfood.service.AttributeValueService;

@Service
public class AttributeValueServiceImpl implements AttributeValueService {

	@Autowired
	private CfAttributeValueMapper valueMapper;
	
	@Override
	public List<CfAttributeValue> getAttributeValue(Integer keyId) {
		CfAttributeValueExample example=new CfAttributeValueExample();
		Criteria criteria = example.createCriteria();
		criteria.andAttributeIdEqualTo(keyId);
		List<CfAttributeValue> list = valueMapper.selectByExample(example);
		return list;
	}

	@Override
	public int insertAttributeValue(CfAttributeValue value) {
		value.setCreateTime(new Date());
		value.setUpdateTime(new Date());
		int i = valueMapper.insertSelective(value);
		return i;
	}

	@Override
	public int updateAttributeValue(CfAttributeValue value) {
		value.setUpdateTime(new Date());
		int i = valueMapper.updateByPrimaryKeySelective(value);
		return i;
	}

	@Override
	public int deleteAttributeValue(CfAttributeValue value) {
		value.setUpdateTime(new Date());
		int i = valueMapper.updateByPrimaryKeySelective(value);
		return i;
	}

}
